//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.soap.utils;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import org.hibernate.validator.HibernateValidator;
import org.hibernate.validator.HibernateValidatorConfiguration;

public class ValidateUtils {
    private static Validator validator = null;
    private static Validator fastValidator = null;

    public ValidateUtils() {
    }

    public static Map<String, String> getErrors(Object obj) {
        Map<String, String> map = new HashMap();
        Set<ConstraintViolation<Object>> constraintViolations = validator.validate(obj, new Class[0]);
        Iterator var3 = constraintViolations.iterator();

        while(var3.hasNext()) {
            ConstraintViolation constraintViolation = (ConstraintViolation)var3.next();
            map.put(constraintViolation.getPropertyPath().toString(), constraintViolation.getMessage());
        }

        return map;
    }

    public static Map<String, String> getGroupErrors(Object obj, Class... clazz) {
        Map<String, String> map = new HashMap();
        Set<ConstraintViolation<Object>> constraintViolations = validator.validate(obj, clazz);
        Iterator var4 = constraintViolations.iterator();

        while(var4.hasNext()) {
            ConstraintViolation constraintViolation = (ConstraintViolation)var4.next();
            map.put(constraintViolation.getPropertyPath().toString(), constraintViolation.getMessage());
        }

        return map;
    }

    public static String getErrorsOne(Object obj) {
        Set<ConstraintViolation<Object>> constraintViolations = fastValidator.validate(obj, new Class[0]);
        Iterator var2 = constraintViolations.iterator();
        if (var2.hasNext()) {
            ConstraintViolation constraintViolation = (ConstraintViolation)var2.next();
            return constraintViolation.getMessage();
        } else {
            return null;
        }
    }

    public static String getGroupErrorsOne(Object obj, Class... clazz) {
        Set<ConstraintViolation<Object>> constraintViolations = fastValidator.validate(obj, clazz);
        Iterator var3 = constraintViolations.iterator();
        if (var3.hasNext()) {
            ConstraintViolation constraintViolation = (ConstraintViolation)var3.next();
            return constraintViolation.getMessage();
        } else {
            return null;
        }
    }

    public static boolean hasError(Object obj) {
        Set<ConstraintViolation<Object>> constraintViolations = fastValidator.validate(obj, new Class[0]);
        return !constraintViolations.isEmpty();
    }

    public static boolean hasGroupError(Object obj, Class... clazz) {
        Set<ConstraintViolation<Object>> constraintViolations = fastValidator.validate(obj, clazz);
        return !constraintViolations.isEmpty();
    }

    static {
        validator = Validation.buildDefaultValidatorFactory().getValidator();
        fastValidator = ((HibernateValidatorConfiguration)Validation.byProvider(HibernateValidator.class).configure()).failFast(true).buildValidatorFactory().getValidator();
    }
}
